import axios from '@/utils/request';

/**
 * 新增秒杀信息
 * @params 秒杀信息
 */
 export async function AddMSpike(params) {
    const res = await axios.post('/Spike/AddMSpike',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 修改秒杀信息
 * @params 秒杀信息
 */
 export async function UpdateSpike(params) {
    const res = await axios.post('/Spike/UpdateSpike',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询秒杀信息
 * @params 秒杀信息
 */
 export async function QuerySpikeByCondition(params) {
    const res = await axios.post('/Spike/QuerySpikeByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 根据秒杀Id查询秒杀信息
 * @params 秒杀Id
 */
 export async function QuerySpikeById(id) {
    const res = await axios.get('/Spike/QuerySpikeById?id='+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 根据秒杀Id删除秒杀信息
 * @params 秒杀Id
 */
 export async function Delete(id) {
    const res = await axios.get('/Spike/Delete/'+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}
